﻿namespace Digitalmes.Application.Sys.Dicts.Commands;

/// <summary>
/// 删除字典指令。
/// </summary>
/// <param name="Id"></param>
public record DeleteDictCommand(long Id) : IRequest<IResult<bool>>;

internal sealed class DeleteDictCommandHandler(IRepository<SysDict> repo) : IRequestHandler<DeleteDictCommand, IResult<bool>>
{
    public async Task<IResult<bool>> Handle(DeleteDictCommand request, CancellationToken cancellationToken)
    {
        var ok = await repo.DeleteByIdAsync(request.Id, cancellationToken);
        return Result.From(ok);
    }
}
